package com.design_pattern.builder;

public class Person {
    private int age;
    private String name;
    private String phone;
    private Location location;

    private Person() {

    }

    public static PersonBuilder builder() {
        return new PersonBuilder();
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public Location getLocation() {
        return location;
    }

    public void setLocation(Location location) {
        this.location = location;
    }

    public static class PersonBuilder {
        private Person person = new Person();

        public PersonBuilder basicInfo(String name, int age) {
            person.setAge(age);
            person.setName(name);
            return this;
        }

        public PersonBuilder phone(String phone) {
            person.setPhone(phone);
            return this;

        }

        public PersonBuilder location(Location location) {
            person.setLocation(location);
            return this;
        }

        public Person build() {
            return person;
        }

    }
}
